<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8"%>
<jsp:useBean id="pageBean" scope="request" class="com.agileai.hotweb.domain.PageBean"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>流程定义设置</title>
<%@include file="/jsp/inc/resource.inc.jsp"%>
<script language="javascript">
function deleteRow(index){
	$("#varIndex").val(index);
	doSubmit({actionType:'delProcessVariable'});
}
function addRow(){
	doSubmit({actionType:'addProcessVariable'});
}
function saveGenerateEdit(){
	var varSize = $('#varSize').val();
	for (var i=0;i < varSize;i++){
		var code = ele("VAR_CODE_"+i).value;
		if (validation.checkNull(code)){
			writeErrorMsg('变量编码不能为空！');
			return;		
		}	
		if (!validation.isCharacter(code)){
			writeErrorMsg('变量编码只能是字母！');
			return;
		}		
	}
	postRequest('form1',{actionType:'save',onComplete:function(responseText){
		if ("success" == responseText){
			alert("保存流程信息成功！");		
		}
	}});
}
function showSecurityConfig(){
	var url = "index?SecurityAuthorizationConfig&resourceType=Process&resourceId=<%=pageBean.inputValue("WFP_ID")%>&height=330&randomKey="+Math.random();
	$('#SecurityFrame').attr('src',url);
}
var addResourceRequestBox;
function openAddResourceRequestBox(){
	var title = "上载资源";
	if (!addResourceRequestBox){
		addResourceRequestBox = new PopupBox('addResourceRequestBox',title,{size:'big',width:'260px',height:'260px',top:'3px'});
	}
	var url = 'index?WfProcessResouceUploader&BIZ_ID='+$('#WFP_ID').val();
	addResourceRequestBox.sendRequest(url);	
}
function delResourceRequest(){
	if (confirm('是否确认要删除附件？')){
		var url = 'index?WfProcessResouceUploader&actionType=delResource&REL_ID='+$('#__ResouceList').val();
		sendRequest(url,{onComplete:function(responseText){
			if ("success"==responseText){
				loadResourceList();
			}
		}});		
	}
}
function loadResourceList(){
	var formSelect = new FormSelect("__ResouceList");
	formSelect.removeAll();
	var url = 'index?WfProcessResouceUploader&actionType=loadResourceList&BIZ_ID='+$('#WFP_ID').val();
	sendRequest(url,{onComplete:function(responseText){
		if ("fail" != responseText){
			var datas = $.parseJSON(responseText);
			if (datas){
				for (var i=0;i < datas.length;i++){
					var data = datas[i];
					var dataText = data.text;
					var dataValue = data.value;
					$('#WFP_LOGO_URL').val(dataText);
					formSelect.addItem(dataText,dataValue);
				}				
				if (datas.length > 0){
					$('#addResourceBtn').disable();
					$('#delResourceBtn').enable();
				}else{
					$('#addResourceBtn').enable();
					$('#delResourceBtn').disable();
				}
			}else{
				$('#addResourceBtn').enable();
				$('#delResourceBtn').disable();
			}
		}else{
			$('#addResourceBtn').enable();
			$('#delResourceBtn').disable();
		}
	}});
}
function refreshPage(){
	loadResourceList();
	addResourceRequestBox.closeBox();

}
</script>
</head>
<body>
<form action="<%=pageBean.getHandlerURL()%>" name="form1" id="form1" method="post">
<%@include file="/jsp/inc/message.inc.jsp"%>
<div id="__ParamBar__" style="float: right;">&nbsp;</div>
<div id="__ToolBar__">
<table border="0" cellpadding="0" cellspacing="1">
<tr height="24px;">
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onclick="saveGenerateEdit()"><input value="&nbsp;" type="button" class="saveImgBtn" id="saveImgBtn" title="保存" />保存</td>
   <td onmouseover="onMover(this);" onmouseout="onMout(this);" class="bartdx" align="center" onclick="javascript:parent.PopupBox.closeCurrent()"><input value="&nbsp;" type="button" class="closeImgBtn" title="关闭" />关闭</td>
</tr>
</table>
</div>
<div class="photobg1" id="tabHeader">
	<div class="newarticle1">基本信息</div>
	<div class="newarticle1">流程变量</div>
	<div class="newarticle1" onclick="showSecurityConfig()">流程权限</div>
</div>
<div class="photobox newarticlebox" id="Layer0" style="height:440px;">
<table class="detailTable" cellspacing="0" cellpadding="0">
<tr>
	<th width="100" nowrap>名称</th>
	<td colspan="3"><input id="WFP_NAME" name="WFP_NAME" type="text" value="<%=pageBean.inputValue("WFP_NAME")%>" size="40" class="text" /></td>
	</tr>
<tr>
	<th width="100" nowrap>编码</th>
	<td><input name="WFP_CODE" type="text" class="text" id="WFP_CODE" value="<%=pageBean.inputValue("WFP_CODE")%>" size="25" readonly="readonly" /></td>
	<th width="100" nowrap>分组</th>
	<td><select name="WFP_GROUP" label="分组" id="WFP_GROUP">
	  <%=pageBean.selectValue("WFP_GROUP")%>
	  </select></td>
</tr>
<tr>
	<th width="100" nowrap>版本</th>
	<td><input name="WFP_VERSION" type="text" class="text" id="WFP_VERSION" value="<%=pageBean.inputValue("WFP_VERSION")%>" size="25" readonly="readonly" label="版本" />
	</td>
	<th width="100" nowrap>状态</th>
	<td><input name="WFP_STATE_NAME" type="text" class="text" id="WFP_STATE_NAME" value="<%=pageBean.selectedText("WFP_STATE")%>" size="25" readonly="readonly" label="状态" />
	  <input name="WFP_STATE" type="hidden" id="WFP_STATE" value="<%=pageBean.selectedValue("WFP_STATE")%>" size="28" readonly="readonly" label="版本" />
	</td>
</tr>
<tr>
	<th width="100" nowrap>创建人</th>
	<td><input name="WFP_CREATER_NAME" type="text" class="text" id="WFP_CREATER_NAME" value="<%=pageBean.inputValue("WFP_CREATER_NAME")%>" size="25" readonly="readonly" label="创建人" />
	  <input name="WFP_CREATER" type="hidden" id="WFP_CREATER" value="<%=pageBean.inputValue("WFP_CREATER")%>" />
	</td>
	<th width="100" nowrap>修改人</th>
	<td><input name="WFP_MODIFIER_NAME" type="text" class="text" id="WFP_MODIFIER_NAME" value="<%=pageBean.inputValue("WFP_MODIFIER_NAME")%>" size="25" readonly="readonly" label="修改人" />
	  <input name="WFP_MODIFIER" type="hidden" id="WFP_MODIFIER" value="<%=pageBean.inputValue("WFP_MODIFIER")%>" />
	</td>
</tr>
<tr>
	<th width="100" nowrap>创建时间</th>
	<td><input label="创建时间" id="WFP_CREATE_TIME" name="WFP_CREATE_TIME" type="text" value="<%=pageBean.inputTime("WFP_CREATE_TIME")%>" size="25" class="text" readonly="readonly" />
	</td>
	<th width="100" nowrap>修改时间</th>
	<td><input label="修改时间" id="WFP_MODIFY_TIME" name="WFP_MODIFY_TIME" type="text" value="<%=pageBean.inputTime("WFP_MODIFY_TIME")%>" size="25" class="text" readonly="readonly" />
</td>
</tr>
<tr>
	<th width="100" nowrap>系统图标</th>
	<td colspan="3"><span style="float:left"><select name="__ResouceList" id="__ResouceList" style="width:400px;"></select></span>
	<span style="margin-left:2px;padding-left:2px;display: inline-block;">
	<div style="margin:1px"><input type="button" name="addResourceBtn" id="addResourceBtn" <%=pageBean.isOnCreateMode()%> value="添加" onclick="openAddResourceRequestBox()" />
    <input type="button" name="delResourceBtn" id="delResourceBtn" <%=pageBean.disabled(pageBean.isOnCreateMode())%> value="删除" onclick="delResourceRequest()" /></div>
	</span>
	</td>
</tr>
<tr>
	<th width="100" nowrap>新建URL</th>
	<td colspan="3"><textarea name="WFP_CREATE_URL" cols="85" rows="2" class="text" id="WFP_CREATE_URL" label="新建URL"><%=pageBean.inputValue("WFP_CREATE_URL")%></textarea>
	</td>
</tr>
<tr>
	<th width="100" nowrap>编辑URL</th>
	<td colspan="3"><textarea name="WFP_MODIFY_URL" cols="85" rows="2" class="text" id="WFP_MODIFY_URL" label="编辑URL"><%=pageBean.inputValue("WFP_MODIFY_URL")%></textarea>
	<img class="varselecter" src="images/varselecter.png" width="20" height="20" onclick="showVariableBox('WFP_MODIFY_URL','primitive')" style="cursor:pointer" />
	</td>
</tr>
<tr>
	<th width="100" nowrap>详情URL</th>
	<td colspan="3"><textarea name="WFP_DETAIL_URL" cols="85" rows="2" class="text" id="WFP_DETAIL_URL" label="详情URL"><%=pageBean.inputValue("WFP_DETAIL_URL")%></textarea>
	<img class="varselecter" src="images/varselecter.png" width="20" height="20" onclick="showVariableBox('WFP_DETAIL_URL','primitive')" style="cursor:pointer" />
	</td>
</tr>
<tr>
	<th width="100" nowrap>移动详情URL</th>
	<td colspan="3"><textarea name="WFP_MDETAIL_URL" cols="85" rows="2" class="text" id="WFP_MDETAIL_URL" label="移动详情URL"><%=pageBean.inputValue("WFP_MDETAIL_URL")%></textarea>
	<img class="varselecter" src="images/varselecter.png" width="20" height="20" onclick="showVariableBox('WFP_MDETAIL_URL','primitive')" style="cursor:pointer" />
	</td>
</tr>
<tr>
	<th width="100" nowrap>备注信息</th>
	<td colspan="3"><textarea label="备注" name="WFP_DESC" cols="85" rows="2" class="text" id="WFP_DESC"><%=pageBean.inputValue("WFP_DESC")%></textarea>
</td>
</table>
</div>
<div class="photobox newarticlebox" id="Layer1" style="height:440px;display:none">
<table id="dataTable" class="dataTable" cellspacing="0"  cellpadding="0">
<tbody>
  <tr>
    <th width="100" align="center" nowrap="nowrap">编码</th>
    <th width="30%" align="center">描述</th>
    <th width="80" align="center">类别</th>
	<th width="60" align="center" nowrap="nowrap">初始值</th>
    <th width="120" align="center" nowrap="nowrap"><input class="formbutton"type="button" name="button7" id="button7" value="新增" onClick="addRow()"/></th>
  </tr>
<%
pageBean.initListAttribute("processVars");
int varSize = pageBean.listSize();
for (int i=0;i < varSize;i++){
%>  
  <tr>
    <td align="center" nowrap="nowrap"><input name="VAR_CODE_<%=i%>" type="text" id="VAR_CODE_<%=i%>" size="10" maxlength="20" value="<%=pageBean.inputValue(i,"VAR_CODE") %>" /></td>
    <td><input name="VAR_DESC_<%=i%>" type="text" id="VAR_DESC_<%=i%>" size="20" maxlength="20" value="<%=pageBean.inputValue(i,"VAR_DESC") %>"/></td>
    <td align="center"><select name="VAR_TYPE_<%=i%>" id="VAR_TYPE_<%=i%>">
	<%=pageBean.selectValue("VAR_TYPE",pageBean.inputValue(i,"VAR_TYPE")) %>
    </select></td>
	<td><input name="VAR_INIT_VALUE_<%=i%>" type="text" id="VAR_INIT_VALUE_<%=i%>" size="10" value="<%=pageBean.inputValue(i,"VAR_INIT_VALUE") %>"/></td> 
    <td style="text-align:center" nowrap="nowrap"><input class="formbutton" type="button" name="delBtn_<%=i%>" id="delBtn_<%=i%>" value="删除" onclick="deleteRow(<%=i%>)"/></td>
  </tr>
<%}%>  
</tbody>
</table>
<input type="hidden" name="varSize" id="varSize" value="<%=varSize%>"/>
</div>
<div class="photobox newarticlebox" id="Layer2" style="height:440px;display:none">
<iframe id="SecurityFrame" src="" width="100%" height="410" frameborder="0" scrolling="no"></iframe>
</div>
<input type="hidden" name="actionType" id="actionType" value=""/>
<input type="hidden" name="operaType" id="operaType" value="<%=pageBean.getOperaType()%>"/>
<input type="hidden" name="WFP_ID" id="WFP_ID" value="<%=pageBean.inputValue("WFP_ID")%>"/>
<input type="hidden" name="WFP_LOGO_URL" id="WFP_LOGO_URL" value="<%=pageBean.inputValue("WFP_LOGO_URL")%>"/>
<input type="hidden" name="varIndex" id="varIndex" value=""/>
<jsp:include page="/jsp/inc/varselecter.inc.jsp" flush="true" />
</form>
<script language="javascript">
lengthValidators[0].set(64).add("WFP_CODE");
lengthValidators[1].set(64).add("WFP_NAME");
lengthValidators[2].set(256).add("WFP_DESC");
rawCharValidator.add("WFP_CODE");
if (isValid($("#WFP_ID").val())){
	loadResourceList();
}
var tab = new Tab('tab','tabHeader','Layer',<%=pageBean.inputValue("currentTabIndex")%>);
tab.focus(<%=pageBean.inputValue("currentTabIndex")%>);
</script>
</body>
</html>
<%@include file="/jsp/inc/scripts.inc.jsp"%>
